import jwt
import datetime

SECRET_KEY = "!Q@W3e4r%T^Y"
class PWT:

    @staticmethod
    def get_token(payload: dict) -> str:
        """
        Generate JWT token with 7 days expiration.
        :param payload: Dictionary containing the claims.
        :return: Generated JWT token as a string.
        """
        expiration = datetime.datetime.utcnow() + datetime.timedelta(days=7)
        payload['exp'] = expiration  # Add expiration time
        token = jwt.encode(payload, SECRET_KEY, algorithm="HS256")
        return token

    @staticmethod
    def verify(token: str) -> dict:
        """
        Verify the JWT token.
        :param token: JWT token to verify.
        :return: Decoded payload if the token is valid.
        :raises: jwt.ExpiredSignatureError or jwt.InvalidTokenError if invalid.
        """
        return jwt.decode(token, SECRET_KEY, algorithms=["HS256"])
